package com.hwadee.hello.advice;

import java.util.Arrays;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.stereotype.Component;

@Component
public class HijackAroundMethod implements MethodInterceptor {

	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		Object obj = null;
		try {
			//这里写之前。。。。。。。
			System.out.print("之前:"+invocation.getMethod().getName() + "--->");
			System.out.println(Arrays.toString(invocation.getArguments()));
			
			obj = invocation.proceed();
			
			System.out.println( "返回之后:" + obj );
			//这里写返回之后.........
		} catch (Exception e) {
			// TODO: handle exception
			System.out.println( invocation.getMethod().getName() + "抛出异常:" + e.getMessage());
			//这里写抛出之后。。。。。。。。
		}
		return obj;
	}

}
